<%@ page language="java" %>

<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
				 com.scalar.chiptrack.users.Functionality,
				 com.scalar.chiptrack.users.User"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/newproformaInvoice.do" />

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>

<SCRIPT language="JavaScript">
window.onload = init;

function init()
{
    qs_1 = new QuickSearch(document.proformaInvoiceForm['searchSalesOrderId'], document.proformaInvoiceForm.qs1, false);
    qs_2 = new QuickSearch(document.proformaInvoiceForm['searchProcessstepId'], document.proformaInvoiceForm.qs2, false);
}

function search()
{
    document.proformaInvoiceForm.searchWithCompulsoryFields.value = 'true';
    document.proformaInvoiceForm.action = "<%=chipTracContext%>/newproformaInvoice.do?action=searchInvoices";
    document.proformaInvoiceForm.submit();
}

function reset()
{
    document.proformaInvoiceForm.reset();
    qs_1.resetQuickSearchCntrl();
    qs_2.resetQuickSearchCntrl();
}
function printView( invoiceId )
{
	newWindow = window.open ('<%=chipTracContext%>/newproformaInvoice.do?action=print_view&invoiceId='+invoiceId,'printerFreindlyPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=800,height=550,resizable=yes');
}
</SCRIPT>
</HEAD>
<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
	<tr>
    	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <%@include file="/jsp/finance/finance_menu.jsp" %>
            <!-- end of the side navigations -->
        </td>
        <td bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></td>
	    <td bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td>
	    <td valign="top" width="100%">
            <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
	        <BR>
        	<html:form name="proformaInvoiceForm" type="com.scalar.chiptrack.finance.proformainvoice.forms.ProformaInvoiceForm" action="/newproformaInvoice.do">
    		<table width="90%" align="center" cellpadding="2" cellspacing="2" border="0">
			    <tr><td colspan="4" class="NArialW" align="center">Search Proforma Invoices</td></tr>
                <tr><td colspan='4' align="left" class='NArialL'>&nbsp;<FONT id="errors" color='FF0000'></font></td></tr>
                <tr><td colspan='4' class="NArialL"><chiptrack:errors styleClass="NArialL"/></td></tr>
                <tr><td colspan='4' class="NArialL"><chiptrack:info styleClass="NArialL"/></td></tr>
                <tr><td colspan='4'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></td></tr>
                <tr>
                    <td class="NArialL">Invoice No.:</td>
                    <td class="NArialL">
                        <html:text property="searchInvoiceNo"  styleClass="txfield" style="width:180px"/>
                    </td>
                    <td class="NArialL">Customer:</td>
                    <td class="NArialL">
                        <html:select property="searchCustomerId"  styleClass="txfield" style="width:180px">
                            <html:option value="-1">All</html:option>
                            <html:options collection="customerList" property="value" labelProperty="label"/>
                        </html:select>
                    </td>
                </tr>
                <tr>
                    <td class="NArialL">
                        Quick Search Sales Order No.:
                    </td>
                    <td class="NArialL">
                        <input type="text" name="qs1" class="txfield" size='26' onkeyup='quickSearch(qs_1)'/>
                    </td>
                    <td class="NArialL" width='30%'>
                        Quick Search Part Number:
                    </td>
                    <td class="NArialL" width='20%'>
                        <input type="text" name="qs2" class="txfield" size='26' onkeyup='quickSearch(qs_2)'/>
                    </td>
                </tr>
                <tr>
                    <td class="NArialL">Sales Order No.:</td>
                    <td class="NArialL">
                        <html:select property="searchSalesOrderId"  styleClass="txfield" style="width:180px">
                            <html:option value="-1">All</html:option>
                            <html:options collection="salesOrderList" property="value" labelProperty="label"/>
                            <%--<logic:present name="lotNumbers">
                                <html:options collection="lotNumbers" property="value" labelProperty="label"/>
                            </logic:present>--%>
                        </html:select>
                    </td>
                    <td class="NArialL">
                        FG Part Number:
                    </td>
                    <td class="NArialL">
                        <html:select property="searchProcessstepId"  styleClass="txfield" style="width:180px">
                            <html:option value="-1">All</html:option>
                            <html:options collection="partNumberList" property="value" labelProperty="label"/>
                        </html:select>
                    </td>
                </tr>
                <tr>
                    <td class="NArialL">&nbsp;</td>
                    <td class="NArialL">
                        &nbsp;
                    </td>
                    <td class="NArialL">Year:</td>
                    <td class="NArialL">
                        <html:select property="searchYear"  styleClass="txfield" style="width:180px">
                            <html:option value="-1">All</html:option>
                            <html:options collection="yearList" property="value" labelProperty="label"/>
                        </html:select>
                        <input type="hidden" name="searchWithCompulsoryFields" />
                    </td>
                </tr>
                <tr><td colspan='4'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='5'></td></tr>
                <tr><td colspan='4'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></td></tr>
                <tr>
                    <td colspan="5" align="center">
                        <a href="javascript:search()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click to Search for Test Release';return true" onmouseout="window.status='';return true" title="Click here to Search for Proforma Invoice"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javascript:reset()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
                    </td>
                </tr>
                <tr>
                    <td colspan='4' class="NArialL">
                        Please
                        <chiptrack:restrictedLink functionality='<%=Functionality.PRO_FORMA_INVOICE %>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href='<%=chipTracContext+"/newproformaInvoice.do?action=searchNew"%>' onmouseover="window.status='Click to Create Proforma Invoice';return true" onmouseout="window.status='';return true">click here</chiptrack:restrictedLink>
                        to generate new Proforma Invoice
                    </td>
                </tr>
                <tr><td colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></td></tr>
                <logic:present name="profromaInvoiceList" scope="request">
                <tr>
                    <td colspan='4'>
                        <table width="100%" align="left" cellpadding="2" cellspacing="2" border="0">
                            <tr>
                                <td width="15%" class="NArialL" bgcolor="#993333" align="center">
                                    <font color="#FFFFFF">Proforma Invoice No</font>
                                </td>
                                <td width="15%" class="NArialL" bgcolor="#993333" align="center">
                                    <font color="#FFFFFF">Date</font>
                                </td>
                                <td width="15%" class="NArialL" bgcolor="#993333" align="center">
                                    <font color="#FFFFFF">Sales Order No.</font>
                                </td>
                                <td width="25%" class="NArialL" bgcolor="#993333" align="center">
                                    <font color="#FFFFFF">Customer Name</font>
                                </td>
                                <td width="10%" class="NArialL" bgcolor="#993333" align="center">
                                    <font color="#FFFFFF">Status</font>
                                </td>
                                <td width="35%" class="NArialL" bgcolor="#993333" align="center">
                                   <font color="#FFFFFF">Actions</font>
                                </td>
                            </tr>
                            <logic:iterate name="profromaInvoiceList" id="lineItem" type="com.scalar.chiptrack.finance.proformainvoice.ProformaInvoiceLineItem" indexId="iteratorIdx" >
                                <tr <%if(iteratorIdx.intValue()%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>>
                                    <td class="NArialL" align="center">
                                        <bean:write name="lineItem" property="invoiceNo" />
                                    </td>
                                    <td class="NArialL" align="center">
                                        <bean:write name="lineItem" property="invoiceDate" />
                                    </td>
                                    <td  class="NArialL" align="center">
                                        <bean:write name="lineItem" property="salesOrderNo" />
                                    </td>
                                    <td class="NArialL" align="center">
                                        <bean:write name="lineItem" property="customerName" />
                                    </td>
                                    <td class="NArialL" align="center">
                                        <bean:write name="lineItem" property="status" />
                                    </td>
                                    <td class="NArialL" align="center" NOWRAP>
                                        <table width="60%" align="center" cellpadding="0" cellspacing="0" border="0">
                                            <tr>
                                                <td class="NArialL" width="30%">
                                                    <a href="javascript:printView(<bean:write name="lineItem" property="invoiceId" />)" onMouseOver="window.status='Click to View Proforma Invoice';return true" onMouseout="window.status='';return ">View</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                                </td>                                                
                                                <logic:notEqual name="lineItem" property="status" value='CANCELLED'>
                                                <td class="NArialL" width="30%">
                                                    <a href='<%=chipTracContext%>/newproformaInvoice.do?action=modify&invoiceId=<bean:write name="lineItem" property="invoiceId" />' onMouseOver="window.status='Click to Modify Proforma Invoice';return true" onMouseout="window.status='';return ">Modify</a>&nbsp;&nbsp;&nbsp;
                                                </td>
                                                <td class="NArialL" width="40%">
                                                    <a href='<%=chipTracContext%>/newproformaInvoice.do?action=cancel&invoiceId=<bean:write name="lineItem" property="invoiceId" />' onMouseOver="window.status='Click to Cancel Proforma Invoice';return true" onMouseout="window.status='';return ">Cancel</a>&nbsp;&nbsp;&nbsp;
                                                </td>
                                                </logic:notEqual>
                                                <logic:equal name="lineItem" property="status" value='CANCELLED'>
                                                <td class="NArialL" width="30%">
                                                    Modify&nbsp;&nbsp;&nbsp;
                                                </td>
                                                <td class="NArialL" width="40%">
                                                    Cancel&nbsp;&nbsp;&nbsp;&nbsp;
                                                </td>
                                                </logic:equal>
                                            </tr>
                                        </table>


                                    </td>
                                </tr>
                            </logic:iterate>
                        </table>
                    </TD>
               </TR>
               </logic:present>
        </table>
	</html:form>
<!-- till here -->
<BR><BR><BR></td>
<td bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></td>
</tr>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>

<%--<% }catch(Exception e){e.printStackTrace();} %>--%>
